<?php

namespace AppBundle\Form;

use AppBundle\Entity\BlogPost;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class BlogPostType extends AbstractType{
    public function buildForm(FormBuilderInterface $builder,array $options){
      $builder
          ->add('title')
          ->add('body',TextareaType::class)
          ->add('draft',ChoiceType::class,array(
              'choices'=>array(
                '是' =>true,
                '否' => false,
               ),
               'choices_as_values'=>true
          ))
          ;
    }

    public function configureOptions(OptionsResolver $resolver){
      $resolver->setDefaults(array(
        'data_class' => BlogPost::class
      ));
    }
}
